import createjs from "createjs-ts"
import cjs=createjs
import DoubleFingerScaleHelper from "../helper/DoubleFingerScaleHelper";
export default class PinchToZoomDemo extends cjs.Container {
    private pic=new cjs.Bitmap('./assets/images/刘亦菲.jpg')
    constructor() {
        super()
        this.addChild(this.pic);
        //绘制三个圆圈，分别代表两个手指触点，一个中间点。
        const p0 = new cjs.Shape();
        p0.graphics.beginStroke("#000000").drawCircle(0,0,15).endStroke();
        //this.p0.setTransform(0,450);
        const p1 = new cjs.Shape();
        p1.graphics.beginStroke("#000000").drawCircle(0,0,15).endStroke();
        //this.p1.setTransform(300,150);
        const p2 = new cjs.Shape();
        p2.graphics.beginStroke("#000000").drawCircle(0,0,15).endStroke();
        //this.p2.setTransform(550,450);
        this.addChild(p2,p1,p0);
        //
        this.on('added',()=>{
            new DoubleFingerScaleHelper(this.pic,
                devicePixelRatio,
                Number.MAX_VALUE,
                Number.MIN_VALUE,
                (tp0:cjs.Point,tp1:cjs.Point,tp2:cjs.Point)=>{
                    //console.log(this.pic.scale)
                    const reg=this.pic.globalToLocal(tp2.x,tp2.y)
                    this.globalToLocal(tp0.x,tp0.y,p0)
                    this.globalToLocal(tp1.x,tp1.y,p1)
                    this.globalToLocal(tp2.x,tp2.y,p2)
                },(tp0:cjs.Point,tp1:cjs.Point,tp2:cjs.Point)=>{
                    const reg=this.pic.globalToLocal(tp2.x,tp2.y)
                    this.globalToLocal(tp0.x,tp0.y,p0)
                    this.globalToLocal(tp1.x,tp1.y,p1)
                    this.globalToLocal(tp2.x,tp2.y,p2)
                })
        },this,true)
    }
}